package deepbrain.simnetwork.loader.matrix;

import java.util.Set;

import deepbrain.simnetwork.exception.SimNetworkException;
import deepbrain.simnetwork.loader.ConnectionsLoader;
import deepbrain.simnetwork.mechanism.Mechanism;
import deepbrain.simnetwork.structure.Connection;
import deepbrain.simnetwork.structure.ConnectionMatrix;

public class MatrixConnectionsLoader<WeightType> implements ConnectionsLoader {

	protected MatrixLoader<ConnectionMatrix<WeightType>, WeightType> matrixLoader;
	protected MatrixConnectionBuilder<WeightType> connectionBuilder;

	public MatrixConnectionsLoader() {
	}

	public MatrixConnectionsLoader(
			MatrixLoader<ConnectionMatrix<WeightType>, WeightType> matrixLoader) {
		this.matrixLoader = matrixLoader;
	}

	public MatrixConnectionsLoader(
			MatrixLoader<ConnectionMatrix<WeightType>, WeightType> matrixLoader,
			MatrixConnectionBuilder<WeightType> connectionBuilder) {
		this.matrixLoader = matrixLoader;
		this.connectionBuilder = connectionBuilder;
	}

	public void setMatrixLoader(
			MatrixLoader<ConnectionMatrix<WeightType>, WeightType> matrixLoader) {
		this.matrixLoader = matrixLoader;
	}

	public void setConnectionBuilder(
			MatrixConnectionBuilder<WeightType> connectionBuilder) {
		this.connectionBuilder = connectionBuilder;
	}

	public Set<Connection<?>> loadConnections(int numOfNodes)
			throws SimNetworkException {
		if (connectionBuilder == null)
			connectionBuilder = new GenericMatrixConnectionBuilder<WeightType>();
		ConnectionMatrix<WeightType> matrix = matrixLoader.loadMatrix();
		return connectionBuilder.buildConnections(matrix);
	}

	public Mechanism[] loadMechanisms(int numOfNodes)
			throws SimNetworkException {
		return null;
	}

}
